package com.jml.event;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;
//实现了接口ApplicationListener，在ApplicationListenerDetector的后置处理器中，把这个类放入AbstractApplicationEventMulticaster的ListenerRetriever的applicationListeners容器中
@Service
public class MyEventListenerService implements ApplicationListener<MyApplicationContextEvent> {

    public MyEventListenerService() {
        System.out.println("MyEventListenerService init");
    }

    @Override
    public void onApplicationEvent(MyApplicationContextEvent event) {
        System.out.println("收到了事件:"+event.getA());
    }
}
